<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Manage existing indices | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'ilm-with-existing-indices.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ilm-with-existing-indices.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ilm-with-existing-indices.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/ilm-with-existing-indices.html" rel="nofollow" target="_blank">../en/ilm-with-existing-indices.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="index-lifecycle-management.html">ILM: Manage the index lifecycle</a></span>
»
<span class="breadcrumb-node">Manage existing indices</span>
</div>
<div class="navheader">
<span class="prev">
<a href="start-stop-ilm.html">« Start and stop index lifecycle management</a>
</span>
<span class="next">
<a href="skipping-rollover.html">Skip rollover »</a>
</span>
</div>
<div class="chapter xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="ilm-with-existing-indices"></a>Manage existing indices<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/ilm-with-existing-indices.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>
<p>If you’ve been using Curator or some other mechanism to manage periodic indices,
you have a couple options when migrating to ILM:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Set up your index templates to use an ILM policy to manage your new indices.
Once ILM is managing your current write index, you can apply an appropriate policy to your old indices.
</li>
<li class="listitem">
Reindex into an ILM-managed index.
</li>
</ul>
</div>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>Starting in Curator version 5.7, Curator ignores ILM managed indices.</p>
</div>
</div>
<h3>
<a id="ilm-existing-indices-apply"></a>Apply policies to existing time series indices<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/ilm-with-existing-indices.asciidoc">edit</a>
</h3>
<p>The simplest way to transition to managing your periodic indices with ILM is
to <a class="xref" href="set-up-lifecycle-policy.html#apply-policy-template" title="Apply lifecycle policy with an index template">configure an index template</a> to apply a lifecycle policy to new indices.
Once the index you are writing to is being managed by ILM,
you can <a class="xref" href="set-up-lifecycle-policy.html#apply-policy-multiple" title="Apply a policy to multiple indices">manually apply a policy</a> to your older indices.</p>
<p>Define a separate policy for your older indices that omits the rollover action.
Rollover is used to manage where new data goes, so isn’t applicable.</p>
<p>Keep in mind that policies applied to existing indices compare the <code class="literal">min_age</code> for each phase to
the original creation date of the index, and might proceed through multiple phases immediately.
If your policy performs resource-intensive operations like force merge,
you don’t want to have a lot of indices performing those operations all at once
when you switch over to ILM.</p>
<p>You can specify different <code class="literal">min_age</code> values in the policy you use for existing indices,
or set <a class="xref" href="ilm-settings.html#index-lifecycle-origination-date"><code class="literal">index.lifecycle.origination_date</code></a>
to control how the index age is calculated.</p>
<p>Once all pre-ILM indices have been aged out and removed,
you can delete the policy you used to manage them.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>If you are using Beats or Logstash, enabling ILM in version 7.0 and onward
sets up ILM to manage new indices automatically.
If you are using Beats through Logstash,
you might need to change your Logstash output configuration and invoke the Beats setup
to use ILM for new data.</p>
</div>
</div>
<h3>
<a id="ilm-existing-indices-reindex"></a>Reindex into a managed index<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ilm/ilm-with-existing-indices.asciidoc">edit</a>
</h3>
<p>An alternative to <a class="xref" href="ilm-with-existing-periodic-indices.html" title="Manage existing periodic indices with ILM">applying policies to existing indices</a> is to
reindex your data into an ILM-managed index.
You might want to do this if creating periodic indices with very small amounts of data
has led to excessive shard counts, or if continually indexing into the same index has led to large shards
and performance issues.</p>
<p>First, you need to set up the new ILM-managed index:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
Update your index template to include the necessary ILM settings.
</li>
<li class="listitem">
Bootstrap an initial index as the write index.
</li>
<li class="listitem">
Stop writing to the old indices and index new documents using the alias that points to bootstrapped index.
</li>
</ol>
</div>
<p>To reindex into the managed index:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
Pause indexing new documents if you do not want to mix new and old data in the ILM-managed index.
Mixing old and new data in one index is safe,
but a combined index needs to be retained until you are ready to delete the new data.
</li>
<li class="listitem">
<p>Reduce the ILM poll interval to ensure that the index doesn’t
grow too large while waiting for the rollover check.
By default, ILM checks rollover conditions every 10 minutes.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT _cluster/settings
{
  "transient": {
    "indices.lifecycle.poll_interval": "1m" <a id="CO436-1"></a><i class="conum" data-value="1"></i>
  }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1135.console"></div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO436-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Check once a minute to see if ILM actions such as rollover need to be performed.</p>
</td>
</tr>
</table>
</div>
</li>
<li class="listitem">
<p>Reindex your data using the <a class="xref" href="docs-reindex.html" title="Reindex API">reindex API</a>.
If you want to partition the data in the order in which it was originally indexed,
you can run separate reindex requests.</p>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>Documents retain their original IDs. If you don’t use automatically generated document IDs,
and are reindexing from multiple source indices, you might need to do additional processing to
ensure that document IDs don’t conflict. One way to do this is to use a
<a class="xref" href="docs-reindex.html#reindex-scripts" title="Modify documents during reindexing">script</a> in the reindex call to append the original index name
to the document ID.</p>
</div>
</div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST _reindex
{
  "source": {
    "index": "mylogs-*" <a id="CO437-1"></a><i class="conum" data-value="1"></i>
  },
  "dest": {
    "index": "mylogs", <a id="CO437-2"></a><i class="conum" data-value="2"></i>
    "op_type": "create" <a id="CO437-3"></a><i class="conum" data-value="3"></i>
  }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1136.console"></div>
<div class="calloutlist">
<table border="0" summary="Callout list">
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO437-1"><i class="conum" data-value="1"></i></a></p>
</td>
<td align="left" valign="top">
<p>Matches your existing indices. Using the prefix for
the new indices makes using this index pattern much easier.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO437-2"><i class="conum" data-value="2"></i></a></p>
</td>
<td align="left" valign="top">
<p>The alias that points to your bootstrapped index.</p>
</td>
</tr>
<tr>
<td align="left" valign="top" width="5%">
<p><a href="#CO437-3"><i class="conum" data-value="3"></i></a></p>
</td>
<td align="left" valign="top">
<p>Halts reindexing if multiple documents have the same ID.
This is recommended to prevent accidentally overwriting documents
if documents in different source indices have the same ID.</p>
</td>
</tr>
</table>
</div>
</li>
<li class="listitem">
<p>When reindexing is complete, set the ILM poll interval back to its default value to
prevent unnecessary load on the master node:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT _cluster/settings
{
  "transient": {
    "indices.lifecycle.poll_interval": null
  }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1137.console"></div>
</li>
<li class="listitem">
<p>Resume indexing new data using the same alias.</p>
<p>Querying using this alias will now search your new data and all of the reindexed data.</p>
</li>
<li class="listitem">
Once you have verified that all of the reindexed data is available in the new managed indices,
you can safely remove the old indices.
</li>
</ol>
</div>
</div>
<div class="navfooter">
<span class="prev">
<a href="start-stop-ilm.html">« Start and stop index lifecycle management</a>
</span>
<span class="next">
<a href="skipping-rollover.html">Skip rollover »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>